<?php
/**
 * Created by PhpStorm.
 * UsersF: Mloong
 * Date: 2019/1/8
 * Time: 14:30
 */

namespace app\admin\controller;


use app\admin\service\FileService;
use Filedemo\EachFile;
use think\facade\Request;

class File extends BaseController
{
    public function index()
    {
        return $this->fetch('/file/file');
    }
    public function eachFile()
    {
        $dir = '../public/uploads/';
        $file = new EachFile();
        $arr = $file->file($dir);
        $service = new FileService();
        $new_arr = $service->eachFile($arr);
        return json([
           'code' => 0,
           'data' => $new_arr,
        ]);
    }
    public function delFile()
    {
        $data = Request::post('data');
        $service = new FileService();
        $bool = $service->delFile($data);
        return $bool;
    }
}